(function() {
  "use strict";
  APP.Views.DialogMessageView = Backbone.View.extend({
    el: '#modal',
    events : {
      'click #dialogMessage-submit': 'submit',
      'click #dialogMessage-cancel': 'cancel'
    },
    initialize: function(params) {
      this.submitCallback = params.submitCallback;
      this.cancelCallback = params.cancelCallback;
      this.body = params.body;
      this.title = params.title;
      if(params.submitText == undefined)
      {
        this.submitText = 'Yes';
      }
      else
      {
        this.submitText = params.submitText;
      }
      if(params.cancelText == undefined)
      {
        this.cancelText = 'No';
      }
      else
      {
        this.cancelText = params.cancelText;
      }
      if(params.submitExists != false)
      {
        this.submitExists = '<button id="dialogMessage-submit" type="button" class="btn btn-default">' + this.submitText +'</button>';
      }
    },
    submit: function(e) {
      e.preventDefault();
      this.$el.modal('hide');
      if (this.submitCallback != undefined) {
        this.submitCallback.obj[this.submitCallback.name]();
      }
    },
    cancel: function(e) {
      e.preventDefault();
      this.$el.modal('hide');
      if (this.cancelCallback != undefined) {
        this.cancelCallback.obj[this.cancelCallback.name]();
      }
    },
    render: function(body, title, submitExists) {
      this.$el.html(_.template($('#dialogMessageTemplate').html(), {
        body: this.body,
        title: this.title,
        submitExists: this.submitExists,
        cancelText: this.cancelText
      }));
      this.$el.modal();
      return this;
    }
  });
}());